// components/background-switcher.vue
<template>
  <view class="change-bg-btn" @click="switchBg">切换背景</view>
</template>

<script>
export default {
  methods: {
    switchBg() {
      const newIndex = (uni.getStorageSync('bgIndex') || 0) === 0 ? 1 : 0
      uni.setStorageSync('bgIndex', newIndex)
      this.$emit('change', newIndex)
    }
  }
}
</script>
<style>
	@import url(./css/background-switcher.css);
</style>